<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function main(config){
            const dbhost =  config && config.db&& config.db.host
            console.log(dbhost)
            const d = config && config.d&& config.d.host
            console.log(d)
            //undefined
            //如果不加前面的判断会报错
            const cachehost = config ?. cache ?. host
            console.log(cachehost)
        }
        //给main传入对象
        main({
            db:{
                host:'192.168.2.1',
                name :'lina'
            },
            cache:{
                host:'192.168.10.1',
                name :'uiuiuiui'
            }
        })
    </script>
</body>
</html>